package com.sghd.candy.module.common.event;

import com.sghd.candy.module.player.manager.Player;
import com.sghd.common.event.Event;
import com.sghd.common.socket.session.Session;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

/**
 * 登录事件体
 */
public class LoginEvent implements IdentityEvent {

	/** 事件名 */
	public static final String NAME = "common:login";

	/** 登录的用户 */
	private Player player;
	/** 会话 */
	private Session session;

	// Getter and Setter ...
	
	@Override
	public long getOwner() {
		return player.getId();
	}

	@Override
	public String getName() {
		return NAME;
	}

	public Session getSession() {
		return session;
	}
	
	public Player getPlayer() {
		return player;
	}

	@Override
	public String toString() {
		return ReflectionToStringBuilder.toString(this);
	}
	
	// Static Method's ...

	/** 构造方法 */
	public static Event<LoginEvent> valueOf(Player player, Session session) {
		LoginEvent body = new LoginEvent();
		body.player = player;
		body.session = session;
		return Event.valueOf(NAME, body);
	}
	
}
